package com.yykj.pay.server.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Builder
@Table(
        uniqueConstraints = {
                @UniqueConstraint(columnNames = {"orderNo"})
        }
)
/**
 * 微信订单
 */
public class Order {

    @Id
    @Column(length = 32)
    @TableId(type = IdType.INPUT)
    public String id;

    @Column(columnDefinition = "varchar(64) DEFAULT '' COMMENT '业务唯一编号'", nullable = true)
    public String orderNo;

    @Column(columnDefinition = "varchar(64) DEFAULT ''  COMMENT '支付账号的微信openid'", nullable = true)
    public String openid;

    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '支付时间'")
    private LocalDateTime payTime;

    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '添加时间'")
    private LocalDateTime createTime;

    @Column(columnDefinition = "int(10) DEFAULT 0 COMMENT '第三方是否回调成功,0:未通知,1:成功,2:失败'", nullable = true)
    private int bizNotifyed;

    @Column(columnDefinition = "int(10) DEFAULT 0 COMMENT '微信是否回调成功过,0:未回调,1:成功'", nullable = true)
    private int notifyed;

    @Column(columnDefinition = "int(10) DEFAULT 0 COMMENT '0:预下单,1:支付成功,2:已退款'")
    private int status;

    @Column(columnDefinition = "int(10) DEFAULT 0 COMMENT '金额,单位:分'")
    private int payAmount;

    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '添加时间'")
    private LocalDateTime refundTime;
}
